//
//  OtherInfoViewController.m
//  ForengnMenu
//
//  Created by @-@ on 16/1/22.
//  Copyright © 2016年 余旺. All rights reserved.
//

#import "OtherInfoViewController.h"
#import "SeeInfoTableViewCell.h"

@interface OtherInfoViewController ()<UITableViewDataSource,UITableViewDelegate>

@property UIButton * button;

@property NSArray * titles;

@property NSArray * subTitles;

@end

@implementation OtherInfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIButton * rightBnt = [UIButton buttonWithType:UIButtonTypeCustom];
    rightBnt.frame = CGRectMake(0, 0, 60, 30);
    [rightBnt setImage:[UIImage imageNamed:@"iconfont-fanhui"] forState:UIControlStateNormal];
    [rightBnt setTitle:@"返回" forState:UIControlStateNormal];
    [rightBnt addTarget:self action:@selector(returnAction) forControlEvents:UIControlEventTouchUpInside];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightBnt];

    
    
    self.otherInfoBGImage.image = [UIImage imageNamed:@"otherInfoBG.jpg"];

}

-(void)returnAction{
    
    [self.navigationController popViewControllerAnimated:YES];

}


//视图将要出现时
-(void)viewWillAppear:(BOOL)animated{
    
    //让导航栏透明
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    
    //让分割线透明
    [self.navigationController.navigationBar setShadowImage:[UIImage new]];
    
}

//当界面消失之前调用
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    
    //让分割线不透明
    [self.navigationController.navigationBar setShadowImage:[UIImage imageNamed:@""]];
    
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 4;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return 1;
    }else{
        return 1;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return 130;
    }else{
        return 47;
    }
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString * identifier;
    if (indexPath.section == 0) {
        identifier = @"cell0";
        
    }else if(indexPath.section == 1){
        identifier = @"cell1";
    }else if (indexPath.section == 2){
        identifier = @"cell2";

    }else{
        identifier = @"cell3";

    }
    
    
    
    SeeInfoTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    
    NSString * string = self.info[@"image"];
    cell.seeHeadImageView.image = [UIImage imageNamed:string];
    
    NSString * string1 = self.info[@"name"];
    cell.seeNameLabel.text = string1;
//    self.title = self.info[@"name"];
    
    UILabel * l = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 80, 40)];
    l.text = self.info[@"name"];
    l.textAlignment = NSTextAlignmentCenter;
    l.textColor = [UIColor whiteColor];
    self.navigationItem.titleView = l;

    
    
    NSString * string2 = self.info[@"sex"];
    cell.seeSexLabel.text = string2;
    
    NSString * string3 = self.info[@"title"];
    cell.seeTitleLabel.text = string3;
    
    NSString * string4 = self.info[@"content"];
    cell.seeContentLabel.text = string4;
    
    NSString * string5 = self.info[@"title1"];
    cell.seeTitle2Label.text = string5;
    
    NSString * string6 = self.info[@"content1"];
    cell.seeContent2Label.text = string6;
    
    NSString * string7 = self.info[@"title2"];
    cell.seeTitle3Label.text = string7;
    
    NSString * string8 = self.info[@"content2"];
    cell.seeContent3Label.text = string8;

    
    self.button = (UIButton *)[cell viewWithTag:100];
    [self.button setTitle:@"关注" forState:UIControlStateNormal];
    [self.button setTitleColor:[UIColor colorWithRed:248/255.0f green:102/255.0f blue:79/255.0f alpha:1.0f] forState:UIControlStateNormal];
    
    return cell;
    
}
//点击时触发
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    //取消选择状态
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

@end
